﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LGCourt.Logic.Common
{
    public class PagingHandler
    {

        /// <summary>
        /// 对搜索到的数据进行分页
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="ExChangeEntity"></param>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <returns></returns>
        public static List<T> GetPageData<T>(List<T> ExChangeEntity, int PageIndex, int PageSize)
        {
            List<T> Result = new List<T>();
            int rowCount = PageIndex * PageSize;
            if (ExChangeEntity.Count >= rowCount)
            {
                for (int i = rowCount - PageSize; i < rowCount; i++)
                {
                    Result.Add(ExChangeEntity[i]);
                }
            }
            else
            {
                if (ExChangeEntity.Count > rowCount - PageSize)
                {
                    for (int i = rowCount - PageSize; i < ExChangeEntity.Count; i++)
                    {
                        Result.Add(ExChangeEntity[i]);
                    }
                }
            }
            return Result;
        }
    }
}
